package com.jh.user.business;

import java.util.Date;
import java.util.List;
import java.util.Map;

import cn.jh.common.exception.ServiceException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import com.jh.user.pojo.User;

public interface UserLoginRegisterBusiness {

	/** 注册成会员 */
	User saveUser(User user);

	/** 判断是否登陆 */
	User isValidUser(String phone, String password, long brandId,String deviceId,String source);

	Map queryGrade(long userId);

	Map queryBandId(String brandId);

	/** 根据id获取用户基本信息 */
	User queryUserById(long userid);

	/** 根据brandid和时间获取当前时间的人数 */
	int queryUserNumByBidandtime(long brandId, Date StartTimeDate, Date endTimeDate);

	User createOutNewUser(User user);

	/** 根据用户的手机号码贴牌获取用户 */
	User queryUserByPhoneBrandid(String phone, long brandid);

	/** 根据用户的手机号码获取用户 */
	User queryUserByPhone(String phone);

	/** 根据users的手机号码获取用户 */
	List<User> queryUsersByPhone(String phone);

	/** 根据手机号码和贴牌id */
	User queryUserByPhoneAndBrandid(String phone, long brandid);

	/** 根据brandId获取用户基本信息 */
	List<User> queryUserByBrandId(long brandId);

	/*** 根据等级和贴牌查询 ***/
	List<User> queryUserByGrade(long brandid, String grade);

	/*** 根据等级和状态查询 ***/
	List<User> queryUserByStatus(long brandid, String status);

	/*** 根据状态查询 ***/
	List<User> queryUserByStatus(String status);

	/** 根据openid获取用户 */
	User queryUserByOpenid(String openid);

	/** 注册创建一个新用户 */
	User createNewUser(User user);

	/** 验证支付密码是否正确 */
	User isPaypassValid(long userid, String paypass);

	/**
	 * 获取用户信息 phone cardNo银行卡号 brandId通道ID brandname通道名称 fullname全称 realname真名
	 * realnameStatus审核状态
	 ***/
	Map findInfoUserByall(long brandid, String fullname, String realnameStatus, String shopsStatus,
								 Date StartTimeDate, Date endTimeDate, Pageable pageable);

	Map findInfoUserByall(String fullname, String realnameStatus, String shopsStatus, Date StartTimeDate,
								 Date endTimeDate, Pageable pageable);

	/** 获取改用户的下级会员 */
	List<User> findAfterUsers(long userid);

	/** 获取改用户的下级会员 */
	List<User> findInfoUsers(Long[] userIds);

	/** 获取改用户的下级会员 */
	List<User> findInfoUsersPageable(Long[] userIds, Pageable pageable);

	Page<User> findByPreUserId(Long preUserId, Pageable pageable);

	/***
	 * 下级会员条件查询
	 **/
	List<User> findUserInfoByall(Long[] str2, String fullname, String realnameStatus, String grade,
										Date StartTimeDate, Date endTimeDate);

	/****
	 * 获取贴牌等级uid
	 ***/
	Long[] queryUserIdByGradeAndBrandId(long brandid, String grade);

	/****
	 * 获取下级会员IDS
	 **/
	Long[] queryUserIdBypreUserIds(Long[] userIds);

	/****
	 * 获取等级下级会员IDS
	 **/
	Long[] queryUserIdBypreUserIdsAndGrade(String grade, Long[] userIds);

	/****
	 * 下级实名状态查询
	 **/
	Long[] queryUserIdBypreUserIdsAndrealnameStatus(String realnameStatus, Long[] userIds);

	// 根据省市县模糊查询用户信息
	List<User> queryUserByProvince(String province, String city, String county, Pageable pageable);

	// 查询该贴牌下的用户数量
	int queryBrandUserCount(long brandId);

	int queryUserAfterTodayCount(long userId, String dateFromStr);

	int queryUserAfterYesterdayCount(long userId, String yesterday);

	//用户注销
	void delUserByUserid(long userid);

	//用户注销user表中记录
	void delUserByUserId(long userid);

	//通过phone和brandid查询用户
	User findUserByIdAndBrandId(long phone,long brandId);

	//根据id查询用户的实名状态
	String  findStatusByUserId(long userId);

	void updateUserStatusByUserId(long userId);

	void save(User user);

	//List<User> findUsersBysqlstr(String sqlstr);

	Page<User> findUsersBywhere(long brandId, String preUserPhone, String phone, String fullName, String realNameStatus, String shopsStatus, Date startTime, Pageable pageable);

	List<User> findUsersBywhere(long brandId, String preUserPhone, String phone, String fullName, String realNameStatus, String shopsStatus, Date startTime);

	User findUserById(long userId);

	User queryUserByPhoneAndPassword(String phone,String passWord);

	List<User> findUsersByInviteCode(String inviteCode);

    long findRoleByPhone(String agent) throws ServiceException;

    long getBrand(long brandId);

	User getPreUserId(long userId);

    Map<String, Object> findUserIdByPhone(String phone, long brandId) throws ServiceException;

    Map<String, Object> findPhoneByUserId(String userIds, long brandId) throws ServiceException;

    Map<String, Object> appFindRoleId(long userId, long brandId) throws ServiceException;
}
